package com.yyx.app1.DiagnosticTools_function.UI;

import android.app.Activity;
import android.app.Fragment;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yyx.app1.CommonControls.ViewPager_SelectButton;
import com.yyx.app1.CommonControls.ViewPager_SelectButton_;
import com.yyx.app1.DiagnosticTools_function.Control.ViewPager.DiagnosticTools_4function_ViewPager;
import com.yyx.app1.MyApp;
import com.yyx.app1.R;
import com.yyx.app1.ui.BottomMenu_Fragment;

import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.FragmentById;
import org.androidannotations.annotations.ViewById;
import org.androidannotations.annotations.res.ColorRes;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by yuexing on 2015/9/9.
 */
@EActivity(R.layout.activity_diagnostictools)
public class DiagnosticTools_Activity extends Activity {
    @ViewById
    ViewPager_SelectButton activity_diagnostictools_b0,activity_diagnostictools_b1,activity_diagnostictools_b2,activity_diagnostictools_b3;

    @ViewById
    DiagnosticTools_4function_ViewPager DiagnosticTools_viewpager;

    @FragmentById
    Fragment diagnostictools_bottommeun;

    @ViewById
    ImageView top_menu_ico;

    @ColorRes
    int app_color,gray_unselcet_font;

    @AfterViews
    public void init()
    {
        try
        {
            top_menu_ico.setImageBitmap(((MyApp)getApplication()).getBaseDataManager().getResDrawable(
                    R.drawable.whitethreeline, top_menu_ico.getWidth(),top_menu_ico.getHeight()));
            ((BottomMenu_Fragment)diagnostictools_bottommeun).setShow("诊疗工具");
            int[] images = new int[] {R.drawable.viewpager1,R.drawable.viewpager2,R.drawable.viewpager3,R.drawable.viewpager4};
            int[] select = new int[]{R.drawable.viewpager1_,R.drawable.viewpager2_,R.drawable.viewpager3_,R.drawable.viewpager4_};
            String[] strings = new String[]{"常用公式","生化血气分析","生化套系分析","粪便常规检查"};
            ViewPager_SelectButton[] buttons =new ViewPager_SelectButton[]{activity_diagnostictools_b0,activity_diagnostictools_b1,activity_diagnostictools_b2,activity_diagnostictools_b3};
            for (int i = 0 ; i < 4 ; ++i)
            {
                buttons[i].bind(strings[i], images[i]);
            }
            buttons[0].getButton_viewpager_image().setImageResource(select[0]);
            buttons[0].getButton_viewpager_text().setTextColor(app_color);
            DiagnosticTools_viewpager.init(buttons,images,select,gray_unselcet_font,app_color);
        }
        catch (Exception e)
        {
            Log.e("异常1510150934",e.toString());
        }
    }

    @Click
    public void activity_diagnostictools_b0()
    {
        DiagnosticTools_viewpager.setCurrentItem(0);
    }
    @Click
    public void activity_diagnostictools_b1()
    {
        DiagnosticTools_viewpager.setCurrentItem(1);
    }
    @Click
    public void activity_diagnostictools_b2()
    {
        DiagnosticTools_viewpager.setCurrentItem(2);
    }
    @Click
    public void activity_diagnostictools_b3()
    {
        DiagnosticTools_viewpager.setCurrentItem(3);
    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK)
        {
            finish();
        }
        return true;
    }
}
